<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img {
            position: relative;
        }
        
        button {
            position: absolute;
            display: block;
            top: 40px;
            left: 300px;
            line-height: 20px;
            text-align: center;
            /* width: 20px; */
            height: 20px;
            border: 1px solid white;
        }
    </style>
</head>

<body>
    <img src="img/广告.png" alt="广告" />
    <button>关闭</button>
    <script>
        // setTimeout(function() {
        //     document.querySelector('img').style.display = "block";
        // }, 5000);

        let flag = true;
        document.querySelector("button").onclick = function() {
                let index = 6;
                let timer = setInterval(function() {

                    index--;
                    document.querySelector('button').innerHTML = index + "秒之后关闭";
                    document.querySelector('button').disabled = "true";
                    if (index == 0) {
                        clearInterval(timer);
                        document.querySelector('img').style.display = "none";
                        document.querySelector('button').disabled = "";
                        document.querySelector('button').innerHTML = "关闭";

                    }
                }, 1000);



            }
            //课堂作业： 将 倒计时的 5,4,3,2,1显示出来
    </script>
</body>

</html>